# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Anton Kudelin <kudelin at protonmail dot com>

_pyname=cylp
pkgname=python-$_pyname
pkgver=0.92.2
pkgrel=1
pkgdesc='A Python interface to CLP, CBC, and CGL to solve LPs and MIPs'
arch=(loong64 x86_64)
url='https://github.com/coin-or/CyLP'
license=(EPL)
depends=(coin-or-cbc
         coin-or-cgl
         coin-or-clp
         coin-or-coinutils
         coin-or-osi
         gcc-libs
         glibc
         python
         python-numpy
         python-scipy)
makedepends=(cython
             python-build
             python-installer
             python-setuptools
             python-wheel)
checkdepends=(python-pytest)
source=(https://github.com/coin-or/CyLP/archive/v$pkgver/$_pyname-$pkgver.tar.gz)
sha256sums=('d107e457754e6da71877f4e192eedd5fdcd80c00c601b4d99fdebc8f9ff9afec')

build() {
  cd CyLP-$pkgver
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  cd CyLP-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
# Prevent from loading the uncompiled cylp
  mv cylp/tests .
  rm -r cylp
# Many tests segfault https://github.com/coin-or/CyLP/issues/105
# test-env/bin/python -m pytest -v'
}
  
package() {
  cd CyLP-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm755 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
